package com.fick.hibernate.dao;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;

import com.fick.hibernate.model.SiteInfo;

/**
 * A data access object (DAO) providing persistence and search support for News
 * entities. Transaction control of the save(), update() and delete() operations
 * can directly support Spring container-managed transactions or they can be
 * augmented to handle user-managed Spring transactions. Each of these methods
 * provides additional information for how to configure it for the desired type
 * of transaction control.
 * 
 * @see com.fick.hibernate.model.News
 * @author MyEclipse Persistence Tools
 */

public class SiteInfoDAO extends BaseHibernateDAO {
	private static final Log log = LogFactory.getLog(SiteInfoDAO.class);

	public void attachClean(SiteInfo instance) {
		log.debug("attaching clean SiteInfo instance");
		try {
			getSession().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachDirty(SiteInfo instance) {
		log.debug("attaching dirty SiteInfo instance");
		try {
			getSession().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public SiteInfo findById(java.lang.Integer id) {
		log.debug("getting SiteInfo instance with id: " + id);
		try {
			SiteInfo instance = (SiteInfo) getSession().get("com.fick.hibernate.model.SiteInfo", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		} finally {
			closeSession();
		}
	}

}